package com.example.huitong.util;

import android.content.Context;

import com.example.huitong.App;

public class NetHelper {
	private static NetHelper mInstance;
	private NetHelper(){};
	public synchronized static NetHelper getInstance(){
		if(mInstance == null){
			mInstance = new NetHelper();
		}
		return mInstance;
	}
	
	private static final String URL_FORMATER = "http://api.ickd.cn/?id=%s&secret=%s&com=%s&nu=%s&type=%s&encode=%s&ord=%s";
	private static final String URL_FORMATER_KUAIDI100 = "http://www.kuaidi100.com/query?type=%s&postid=%s&id=1&valicode=&temp=0.745760798221454";
	private static final String AICHA_ID = "103655";
	private static final String AICHA_SCERET = "b8112a06429a512a0e2fd6bdba8c5b4d";
	
	
	/**
	 * http://api.ickd.cn/?id=[]&secret=[]&com=[]&nu=[]&type=[]&encode=[]&ord=[]&lang=[]
	 * http://api.ickd.cn/?id=103655&secret=b8da1ca50642f12396856d2748f36b8e&com=zhongtong&nu=761303055403&type=json&encode=utf8&ord=asc
	 * */
	public String getExpressLogistics(String exp_name, String num){
		if(!App.getApp().isNetworkConnected()){
//			App.getApp().toastShort(context, "网络未连接");
			return null;
		}
		String url = constructQueryUrl(exp_name, num);
		return NetUtil.getContentByUrl(url);
	}
	
	private String constructQueryUrl(String exp_name, String num){
		String url = String.format(URL_FORMATER_KUAIDI100, exp_name, num);
		return url;
	}
}
